package com.qianfeng.zw.meilishuo.fragment;


import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.jayqqaa12.abase.core.fragment.AFragment;
import com.qianfeng.zw.meilishuo.R;
import com.qianfeng.zw.meilishuo.adapter.TabPagerAdater;
import com.viewpagerindicator.TabPageIndicator;

import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.ViewById;

import java.util.ArrayList;

@EFragment(R.layout.fragment_home)
public class HomeFragment extends AFragment {
    @ViewById(R.id.fragment_home_viewpager)
    ViewPager viewPager;
    TabPagerAdater tabPagerAdater;
    ArrayList<AFragment> fragments = new ArrayList<>();
    @ViewById(R.id.title_indicator)
    TabPageIndicator tabIndicator;

    private final String[] titles = {"流行", "热销", "店铺"};

    /**
     * @param inflater
     * @param container
     * @param savedInstanceState
     * @return
     */
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_home, container, false);
        return view;
    }

    protected void init() {
        fragments.add(new FashionFragment_());
        fragments.add(new HotSellFragment_());
        fragments.add(new HdStreetFragment_());
        tabPagerAdater = new TabPagerAdater(titles, fragments, getChildFragmentManager());
        viewPager.setAdapter(tabPagerAdater);
        tabIndicator.setViewPager(viewPager);
    }
}


/**
 * Error:Execution failed for task ':app:dexDebug'.
 * > com.android.ide.common.process.ProcessException:
 * org.gradle.process.internal.ExecException: Process
 * 'command '/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin/java''
 * finished with non-zero exit value 2
 */
